#ifndef AN_GLOBAL_H
#define AN_GLOBAL_H

#include <QString>
#include <QMutex>
#include <QApplication>
#include "AnCallback.h"
#include "AnSysCallback.h"

/**
 * 发生错误的json
 */
#define AN_ERROR_RESPONSE \
	"{\"name\":\"error\", \"status\":\"error\"}"

/**
 * json中用到的字符串常量
 */
#define RESULT "result"
#define SUCCEED "succeed"
#define FAILD "faild"
#define	STATUS "status"
#define RESPONSE "response"
#define REQUEST "request"
#define DATA "data"
#define NAME "name"
#define ERROR "error"
#define DESC "desc"
#define MSG "message"
#define USER "user"
#define SYSTEM "system"
#define APP_NAME "label"
#define PACK_NAME "package_name"
#define INS_D "install_date"
#define VER "version"
#define PATH "path"
#define TYPE "type"
#define SIZE "size"
#define UP_DATE "update_date"
#define FILES "files"
#define LOC_PATH "local_path"
#define REM_PATH "remote_path"

#ifdef Q_OS_WIN
#define SCREENCAP_LOC_PC ".\\sc.png"
#else
#define SCREENCAP_LOC_PC "./sc.png"
#endif

#define SCREENCAP_LOC_AN "/sdcard/sc.png"

#define SCREENCAP_W 270
#define SCREENCAP_H 480

#define DESP_REQS "request: \n"
#define DESP_RESP "response: \n"

#define YES 1
#define NO 0

#define CUR_PATH QString("当前路径：")

class AnAdbServer;					//前向性声明

extern QString adb_path;			//adb可执行文件的路径
extern int port;					//连接的端口
extern AnAdbServer * adb_server;	//管理请求的类
extern QString hostname;			//要连接的主机

extern QString current_devices_id;

extern QMutex device_connect_lock;  //设备是否在连接的锁
extern QMutex device_close_lock;

extern AnSysCallback * sys_callback;

extern int adb_installed;
extern QApplication * app;



extern QMutex lock_devices_check;
extern QMutex lock_devices_info;
extern QMutex lock_app_list;
extern QMutex lock_app_install;
extern QMutex lock_app_uninstall;
extern QMutex lock_file_list;
extern QMutex lock_file_import;
extern QMutex lock_file_export;
extern QMutex lock_contacts_backup;
extern QMutex lock_contacts_recovery;
extern QMutex lock_connect_build;
extern QMutex lock_connect_close;
extern QMutex lock_screencap;

/**
 * @brief The AnGlobal class 用于初始化的类
 */
class AnGlobal
{
public:
	/**
	 * @brief globalInit 用于全局变量的初始化
     * @
	 */
    static void globalInit();

    /**
     * @brief globalFinal 进行全局变量的回收处理
     */
    static void globalFinal();

    static int is_connecting();

    static int is_request_processing(QString request_name);

    static void log_show(QJsonObject json_o, QString desp = "");


};

#endif
